import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import Error from '@/views/Error.vue'
// 引入依赖
import autoRouter from 'vue-router-auto'
const routes = autoRouter({
  // 页面级的.vue存放位置，必传
  rc: require.context('@/views/'+process.env.VUE_APP_PAGES, true, /\.vue$/),
  // '/'的重定向，可选，默认为''
  redirect: process.env.VUE_APP_PAGE_HOME,
  // 页面级的.vue存放的文件夹，可选，默认为:views
  rootFile: 'views/'+process.env.VUE_APP_PAGES,
})
routes.push(
  {
    path: '/error',
    name: 'Error',
    meta: { issysrouter: true },
    component: Error
  }
)
routes.push(
  {
    path: '/about',
    name: 'About',
    meta: { issysrouter: true },
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '@/views/About.vue')
  }
)
routes.push(
  {
    path: '/Login',
    name: 'login',
    meta: { issysrouter: true },
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '@/views/Login.vue')
  }
)
const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  // createWebHashHistory hash 路由 
  // createWebHistory history 路由
  // createMemoryHistory 带缓存 history 路由
  routes
})

export default router